﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace JX.Infrastructure.Common
{
	/// <summary>
	/// 数据库配置，在appsettings.json文件中
	/// </summary>
	public class DatabaseConfig
	{
		/// <summary>
		/// 主库连接字符串
		/// </summary>
		[DisplayFormat(ConvertEmptyStringToNull = false)]
		public string WriteDB { get; set; } = string.Empty;

		/// <summary>
		/// 从库连接字符串，多个从库用“,”分隔
		/// </summary>
		[DisplayFormat(ConvertEmptyStringToNull = false)]
		public string ReadDB { get; set; } = string.Empty;

		/// <summary>
		/// 从库策略 0：随机；1：轮询；
		/// </summary>
		[DisplayFormat(ConvertEmptyStringToNull = false)]
		public int QueryDBStrategy { get; set; } = 0;

		/// <summary>
		/// SQL命令执行超时前的秒数（默认60秒）
		/// </summary>
		[DisplayFormat(ConvertEmptyStringToNull = false)]
		public int CommandTimeout { get; set; } = 60;

		/// <summary>
		/// 数据库提供者类型：sqlserver、mysql
		/// </summary>
		[DisplayFormat(ConvertEmptyStringToNull = false)]
		public string ProviderName { get; set; } = "sqlserver";
	}
}
